﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class cms_cmsSolutions : System.Web.UI.Page
{
    private const string ImageBanner = "solution-banner.png";
    private const string ImageIphoneAdd = "iphone-add.jpg";
    private const string ImageThings = "things.jpg";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadImageDesign();
        }
    }

    private void LoadImageDesign()
    {
        if (File.Exists(Server.MapPath("~/images/" + ImageBanner)))
        {
            imgBanner.ImageUrl = "~/images/" + ImageBanner;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageBanner));
            lblSize.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
        if (File.Exists(Server.MapPath("~/images/" + ImageIphoneAdd)))
        {
            imgIphoneAdd.ImageUrl = "~/images/" + ImageIphoneAdd;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageIphoneAdd));
            lblSizeContact.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
        if (File.Exists(Server.MapPath("~/images/" + ImageThings)))
        {
            imgThings.ImageUrl = "~/images/" + ImageThings;
            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/images/" + ImageThings));
            lblSizeWhatCan.Text = "(H x W:" + img.Height + " x " + img.Width + " )";
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (FileUploadBanner.HasFile && Utils.IsImageFile(FileUploadBanner.FileName))
        {
            FileUploadBanner.SaveAs(Server.MapPath("~/images/" + ImageBanner));
        }
        if (FileUploadIphoneAdd.HasFile && Utils.IsImageFile(FileUploadIphoneAdd.FileName))
        {
            FileUploadIphoneAdd.SaveAs(Server.MapPath("~/images/" + ImageIphoneAdd));
        }        
        if (FileUploadThings.HasFile && Utils.IsImageFile(FileUploadThings.FileName))
        {
            FileUploadThings.SaveAs(Server.MapPath("~/images/" + ImageThings));
        }
    }
}